﻿$(function () {
    $('#accordion').accordion({
        heigstyle: 'content',
        header: 'h3',
        icons: {
            "header": "ui-icon-plus",
            "activeHeader": "ui-icon-minus",
        },
    });
    $(".js-keyword").bind("click", function () {
        $(".guanxin").css({
            "border-width": "1px",
            "border-style": "solid",
            "border-color": "#11b1ce",
        });
        $(".js-search").css({
            "background-image": "url('../../image/serchhei.gif')",
        });
    })
    $(".remenfenlei").bind("click", function () {
        $(".remenfenlei").css({
            "border-bottom": "2px solid #99a1a6",
            "color": "#363d40",
        });
        $(".huifufenlei").css({
            "border-bottom": "none",
            "color": "#7e878c",
        });
    })
    $(".huifufenlei").bind("click", function () {
        $(".huifufenlei").css({
            "border-bottom": "2px solid #99a1a6",
            "color": "#363d40",
        });
        $(".remenfenlei").css({
            "border-bottom": "none",
            "color": "#7e878c",
        });
    })
    $("#title").bind("click", function () {
        $("#title").css({
            "border": "1px solid #99a1a6",
        });

    })
    $(".curr").bind("click", function () {
        if ($.cookie('cookiename')) {
            $("#question").dialog("open");
        }
        else {
            $('#error').dialog('open');
            setTimeout(function () {
                $('#error').dialog('close');
                window.location.href = "/Logn/Index";
            }, 1000)
        }
    })
    $('#question').dialog({
        autoOpen: false,
        modal: true,
        resizable: false,
        width: 500,
        height: 380,
        buttons: {
            '提交': function () {
                $(this).submit();
            }
        }
    });
    $('.uEditorCustom').uEditor();
    $('#error').dialog({
        autoOpen: false,
        modal: true,
        closeOnEscape: false,
        resizable: false,
        draggable: false,
        width: 180,
        height: 50,
    }).parent().find('.ui-widget-header').hide();
    var yincang = $(".yincangyu").html();
    $(".touxiangbejing").attr("src", yincang);
    //获取焦点  显示中央
    $(".buttonhuifu").bind("click", function () {
        $(".shuruwenben")[0].focus();
        var heighe = $(".shuruwenben").offset().top;
        $("body").scrollTop(heighe);
    });
    $("#quick_reply").bind("click", function () {
        $(".shuruwenben")[0].focus();
        var heighe = $(".shuruwenben").offset().top;
        $("body").scrollTop(heighe);
    });
    //回答提交事件
    $("#questingfrom").submit(function (e) {
        if ($(".shuruwenben").val().length == 0) {
            e.preventDefault();
            $(".shuruwenben")[0].focus();
            var heighe = $(".shuruwenben").offset().top;
            $("body").scrollTop(heighe);
        }
        else {
            return true;
        }
    });
    //子回复的回答事件
    $("#zihuifufabiao").bind("click", function () {
        $("#zihuifuconfabiaofrom").submit(function (e) {
            if ($(".zishuruwenben").val().length == 0) {
                e.preventDefault();
                $(".zishuruwenben")[0].focus();
                var heighe = $(".zishuruwenben").offset().top;
                $("body").scrollTop(heighe);
                alertwin("提示","回答不能为空");
            }
            else if ($(".zishuruwenben").val().indexOf(":") <= 0)
            {
                e.preventDefault();
                $(".zishuruwenben")[0].focus();
                var heighe = $(".zishuruwenben").offset().top;
                $("body").scrollTop(heighe);
                alertwin("提示","请不要改变回复的默认格式");
            }
            else {
                return true;
            }
        })
    });
    function alertwin(tilele, content) {
        $.alert({
            title: tilele,
            content: content,
            confirmButton: '确认',
            columnClass: 'col-md-4 col-md-offset-4',

        });
    }
    //我也说一句时间
    $(".shuo").bind("click", function () {
        $(this).parent(".zihuifuconbutton").find(".zihuifuconfabiao").slideDown(200);
        $(this).parent(".zihuifuconbutton").find(".bushuo").css("display", "block");
        $(this).css("display", "none");
        var louzhu = $(this).parents().eq(3).find(".biasohiziduan").html();
        $(this).parent(".zihuifuconbutton").find(".zishuruwenben").val(louzhu+":");

    })
    $(".bushuo").bind("click", function () {
        $(this).parent(".zihuifuconbutton").find(".zihuifuconfabiao").slideUp(200);
        $(this).parent(".zihuifuconbutton").find(".shuo").css("display", "block");
        $(this).parent(".zihuifuconbutton").find(".bushuo").css("display", "none");
        $(this).parent(".zihuifuconbutton").find(".zishuruwenben").val("");
    })
})